package com.norbitltd.guavaleaves.java.lang;

import com.google.common.base.Function;

public class IntegerFunctions extends ObjectFunctions {

	public static Function<Integer, Integer> abs() {
		return new Function<Integer, Integer>() {
			public Integer apply(Integer input) {
				if( input == null ) {
					return null;
				} else {
					return Math.abs(input);
				}
				
			}
		};
	}
	
	public static Function<Integer, Integer> min(final Integer value) {
		return new Function<Integer, Integer>() {
			public Integer apply(Integer input) {
				if( input == null ) {
					return null;
				} else {
					return Math.min(input, value);
				}
				
			}
		};
	}
	
	public static Function<Integer, Integer> max(final Integer value) {
		return new Function<Integer, Integer>() {
			public Integer apply(Integer input) {
				if( input == null ) {
					return null;
				} else {
					return Math.max(input, value);
				}
				
			}
		};
	}
 }
